package com.bawei.library_common.adapter

import android.content.Context
import android.graphics.Bitmap
import android.text.TextUtils
import android.view.ViewGroup
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bawei.library_common.BaseApplication

import com.bawei.library_common.utils.ImageUtils
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget


/**
 * @Author : yaotianxue
 * @Time : On 2023/6/20 15:58
 * @Description : ImageAdapter
 */
class ImageAdapter {
    companion object{

        @BindingAdapter("imageUrl")
        @JvmStatic
        fun imageUrl(imageView: ImageView, url:String){
            if(!TextUtils.isEmpty(url)){
                ImageUtils.loadIntoImageView(BaseApplication.instance,url,imageView)
            }
        }

        @BindingAdapter("imageCircleUrl")
        @JvmStatic
        fun imageCircleUrl( imageView: ImageView, url:String){
            if(!TextUtils.isEmpty(url)){
                ImageUtils.loadCircleIntoImageView(BaseApplication.instance,url,imageView)
            }
        }

        @BindingAdapter("imageRoudendUrl")
        @JvmStatic
        fun imageRoudendUrl( imageView: ImageView, url:String){
            if(!TextUtils.isEmpty(url)){
                ImageUtils.loadRoundedIntoImageView(BaseApplication.instance,url,imageView)
            }
        }


//        //做背景图
//        @BindingAdapter("imageBgUrl")
//        @JvmStatic
//        fun imageUrl(context: Context, viewGroup:ViewGroup, url:String){
//            if(!TextUtils.isEmpty(url)){
//                Glide.with(context)
//                    .load(url)
//                    .into()
//            }
//        }



    }

}